<template>
    <n-modal :show="showModal" :mask-closable="false">
        <n-card style="width: 600px" :bordered="false" size="huge" role="dialog" aria-modal="true">
            <template #header>
                <div class="text-center font-bold">关闭提示</div>
            </template>
            <template #header-extra>
                <div class="cursor-pointer" @click="closeModal">
                    <Icon icon="majesticons:close" width="1.5rem" height="1.5rem" />
                </div>
            </template>
            <template #default>
                <n-radio-group v-model:value="radioValue" name="radiogroup" class="grid gap-y-4 justify-center">
                    <n-radio v-for="item in RadioList" :key="item.label" :value="item.value">
                        {{ item.label }}
                    </n-radio>
                </n-radio-group>
            </template>
            <template #footer>
                <div class="flex items-center justify-between">
                    <n-checkbox v-model:checked="checkBoxValue">不再显示</n-checkbox>
                    <n-button type="success" class="w-25" @click="onClick">确定</n-button>
                </div>
            </template>
        </n-card>
    </n-modal>
</template>

<script setup lang='ts'>
import { useConfigStore } from "@/store";
import { Icon } from "@iconify/vue";
import {
    NModal,
    NCard,
    NRadio,
    NRadioGroup,
    NButton,
    NCheckbox,
} from "naive-ui";
import { ref } from "vue";
const electron = require("electron");
const { ipcRenderer } = electron;

const ConfigStore = useConfigStore()
const props = defineProps({ showModal: Boolean })
const emit = defineEmits(['closeModal'])
const radioValue = ref(ConfigStore.closeType);
const checkBoxValue = ref(ConfigStore.closeTypeTip);

const RadioList = [
    {
        value: "tray",
        label: "最小化系统到托盘",
    },
    {
        value: "close",
        label: "退出DeskTool",
    },
];
const closeModal = () => {
    emit('closeModal')
};
const onClick = () => {
    useConfigStore().setCloseConfig({ type: radioValue.value, tip: checkBoxValue.value })
    emit('closeModal')
    ipcRenderer.send("mainWindow:opreate", radioValue.value);
};

</script>

<style></style>